import { createStore } from 'vuex'
import menus from './modules/menus'
import router, { mainRouter } from '@/router'
import { navigationList } from './nav-list'

const state = {
  showNavbar: false,
  currentSection: ''
}
const mutations = {
  setShowNavbar: (state: any, data: boolean) => state.showNavbar = data,
  setCurrentSection: (state: any, data: string) => state.currentSection = data,
}
const actions = {
  logout() {
    router.push('/login')
  }
}
const getters = {
  mainNavebarList() {
    let list = mainRouter.map((el: any) => ({
      value: el.path,
      name: el.meta.title,
      icon: el.meta.icon
    }))
    list.shift()
    return list
  },
  navigationNavebarList() {
    return navigationList
  },
  getShowNavbar: (state: any) => state.showNavbar,
  getCurrentSection: (state: any) => state.currentSection,
}
export default createStore({
  state,
  mutations,
  actions,
  getters,
  modules: {
    menus
  }
})
